package io.renren.modules.wms.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.modules.wms.entity.PictureInfoEntity;
import io.renren.modules.wms.service.PictureInfoService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 图片信息表
 *
 * @author lain
 * @email 494576412@qq.com
 * @date 2019-07-04 16:45:20
 */
@RestController
@RequestMapping("/wms/pictureinfo")
public class PictureInfoController {
    @Autowired
    private PictureInfoService pictureInfoService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("wms:pictureinfo:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = pictureInfoService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("wms:pictureinfo:info")
    public R info(@PathVariable("id") Integer id){
		PictureInfoEntity pictureInfo = pictureInfoService.getById(id);

        return R.ok().put("pictureInfo", pictureInfo);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
//    @RequiresPermissions("wms:pictureinfo:save")
    public R save(@RequestBody PictureInfoEntity pictureInfo){
		return pictureInfoService.saveWeiBoPic(pictureInfo);
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("wms:pictureinfo:update")
    public R update(@RequestBody PictureInfoEntity pictureInfo){
		pictureInfoService.updateById(pictureInfo);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("wms:pictureinfo:delete")
    public R delete(@RequestBody Integer[] ids){
		pictureInfoService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
